#
# Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
#
# GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
# Author: Shawn.Tan
# Date: 2025.10.28
#
# History: Initial Version 2025.10.28
#
#
from gpgpu.EnvGPGPU import EnvGPGPU
from gpgpu.GenThreadGPGPU import GenThreadGPGPU
from base.Sequence import Sequence
from DV.gpgpu.trees.instruction_tree import ALU_Int32_instructions
from DV.gpgpu.trees.instruction_tree import ALU_Float_Double_instructions


class MyMainSequence(Sequence):

    # Main sequence which calls the other sequences.
    def generate(self, **kwargs):

        i100_seq = I100Sequence(self.genThread)
        i100_seq.run()

        f100_seq = F100Sequence(self.genThread)
        f100_seq.run()


class I100Sequence(Sequence):

    # generate 100 random integer 32 ALU ops
    def generate(self, **kargs):

        for _ in range(100):
            the_instruction = self.pickWeighted(ALU_Int32_instructions)
            self.genInstruction(the_instruction)
            self.notice(">>>>>  The instruction:  {}".format(the_instruction))


class F100Sequence(Sequence):

    # Generate 100 random floating point alu ops
    def generate(self, **kargs):

        for _ in range(100):
            the_instruction = self.pickWeighted(ALU_Float_Double_instructions)
            self.genInstruction(the_instruction)
            self.notice(">>>>>  The instruction:  {}".format(the_instruction))


#  Points to the MainSequence defined in this file
MainSequenceClass = MyMainSequence

#  Using GenThreadGPGPU by default, can be overriden with extended classes
GenThreadClass = GenThreadGPGPU

#  Using EnvGPGPU by default, can be overriden with extended classes
EnvClass = EnvGPGPU
